package com.lablzh.gdxy.repository.activity;

import com.lablzh.gdxy.entity.activity.StudentTeam;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface StudentTeamRepository extends JpaRepository<StudentTeam,Integer> {
    StudentTeam findByTeamNameAndStudentUsername(String teamName, String username);

    List<StudentTeam> findAllByTeamName(String teamName);

    @Modifying
    @Transactional
    @Query("update StudentTeam set audit=?2 where id=?1")
    void updateAuditById(Integer id, String audit);

    List<StudentTeam> findAllByStudentUsername(String username);

    @Transactional
    void deleteAllByTeamName(String teamName);

    @Transactional
    void deleteAllByTeamNameAndStudentUsername(String teamName, String username);
}
